from zeus.operation_service.app.constant import ResultCodeEnum


class PluginResultCode(ResultCodeEnum):
    """
    插件错误码枚举类
    """
    SUCCESS = (1000, '成功')
    ERROR = (1001, '错误')
    FAILED = (1002, '失败')
    PARTIAL_PASSED = (1003, '部分通过')
    PRE_DEPENDENCY_ERROR = (1004, '前置依赖报错')

    UNKNOWN = (1005, '未知异常')


class TaskResultCode(ResultCodeEnum):
    """
    任务状态码
    """
    SUCCESS = (200, '成功')
    RUNNABLE = (201, '就绪')
    RUNNING = (202, '执行中')
    PAUSE = (203, '暂停')
    CANCELED = (204, '已取消')
    PARTIAL_PASSED = (206, '部分成功')
    TIMEOUT = (207, '超时')
    WAITING = (208, '等待')
    NO_DATA_REPORTED = (209, '数据上报失败')
    FAILED = (400, '失败')
    SERVER_RESTART = (401, '服务重启')
    RECOVER = (402, '待加固')
    UNKNOWN = (600, '异常')


class ItemResultCode(ResultCodeEnum):
    """
    任务项状态码
    """
    ITEM_SUCCESS = (0, '成功')
    ITEM_FAILED = (1, '失败')
    ITEM_RECOVER = (5, '待加固')
    ITEM_TIMEOUT = (101, '执行超时')
    ITEM_EXCEPTION = (102, '执行异常')


class WorkFlowResultCode(ResultCodeEnum):
    """
    任务流错误码枚举类
    """
    SUCCESS = (4001001, "task successfully")
    NORMAL = (4001002, "workflow running")

    ERR_WORKFLOW_PARSE = (4002001, "workflow parse error")
    ERR_WORKFLOW_JOB_NAME = (4002002, "job name error, should not be null")
    ERR_WORKFLOW_HOST_NAME = (4002003, "host name error, should not be null")
    ERR_WORKFLOW_STEPS_NULL = (4002004, "steps error, should not be null")
    ERR_WORKFLOW_TIMEOUT = (4002005, "workflow execute timeout")
    ERR_WORKFLOW_EXECUTE = (4002006, "workflow run error")
    ERR_WORKFLOW_CIRCLE = (4002007, "workflow relation circle")

    ERR_UNKNOWN = (4002999, 'Unknown error in Asset')


class RunningTaskResultCode(ResultCodeEnum):

    ERR_NO_DATA_REPORTED = (1010012001, "No data reported")
    ERR_INVALID_TASK_RESULT_DATA = (1010012002, "An inspection item of a specific task contains multiple results.")


class AssetOperationResultCode(ResultCodeEnum):
    """
    巡检包管理API错误码枚举类
    """
    SUCCESS_UPLOAD = (1020041001, "upload asset successfully")
    SUCCESS_DELETE = (1020041002, "delete asset successfully")

    ERR_ASSETS_CHECK = (1020042001, "assets check error")
    ERR_ASSET_EXISTS_IN_SERVER = (
        1020042002, "asset exists on the server, please check upload_file dir")
    ERR_ASSETS_ADD = (1020042003, "add assets error")
    ERR_ASSETS_CONFLICT = (1020042007, "asset exists")
    ERR_ASSETS_PARAMETER = (1020042008, "parameter of config file undefined")
    ERR_ASSETS_SCENE = (1020042009, "asset scene field validate error")
    ERR_ASSETS_ITEM_PARSE = (1020042010, "item parse failed")
    ERR_ASSETS_SCENE_PARSE = (1020042011, "scene parse failed")
    ERR_ASSETS_KEY_VALUE = (1020042012, "asset key error")
    ERR_ASSETS_TIMESTAMP = (1020042013, "asset timestamp not consistent, please download again")
    ERR_ASSETS_DOWNLOAD_CONFLICT = (1020042014, "asset download failed, asset conflict; please reflush")
    ERR_UNKNOWN = (1020042999, 'Unknown error in Asset')

class InstallOSMindResultCode(ResultCodeEnum):
    SUCCESS_QUERY_INSTALL_STATUS = (1020051001, 'Install status queried successfully')
    SUCCESS_QUERY_UPLOADED_PKGS = (1020051002, 'Uploaded packages queried successfully')
    SUCCESS_UPLOAD_PKG = (1020051003, 'Upload package successfully')
    SUCCESS_DELETE_PKG = (1020051004, 'Delete package successfully')
    SUCCESS_START_INSTALL = (1020051005, 'Start install successfully')
    SUCCESS_START_UNINSTALL = (1020051006, 'Start uninstall successfully')

    ERR_INVALID_MODULE_NAME = (1020052001, 'Invalid module name')
    ERR_INSTALL_MODULE_ON_TOO_MANY_NODE = (1020052002, 'Install module on too many node')
    ERR_MODULE_HAS_BEEN_INSTALLED = (1020052003, ' Module has been installed')
    ERR_INVALID_DATA = (1020052004, 'Invalid data in serializer')
    ERR_REQUIRED_MODULE_NOT_EXIST = (1020052005, 'Required module not exist')
    ERR_UNSUPPORTED_SYSTEM = (1020052006, 'Unsupported system')
    ERR_NOT_FOUND_PACKAGE = (1020052007, 'Not found package')
    ERR_CONCURRENT_TASK_FAILED = (1020052008, 'Failed to install other modules')

    ERR_UNKNOWN = (1020052999, 'Unknown error')
